/**
我的项目
*/
define(["jquery","knockout","text!static/pages/home/tpl/myproject.tpl.html","baseview","common"],function($,ko,template,BaseView,Common){
	var enterpriseid;
	var self = '';
	var view = BaseView.extend({
		setTemplate: function(option) {			
			this.el.html(template);
			enterpriseid = Common.userContext().enterpriseId;
		},
		bindEvents: function() {
		},
        fireEvents: function() {
	        self = this;
			/*加载datatable数据*/
			 self.viewmodel.loadDatas()
		},
		events: function() {},
		viewmodel: {
			el:"#myproject",
			quotEntityDataTable: new $.DataTable({
	            params: {
	                "cls": "com.yonyou.ipu.entity.quotation.IpuQuotation"
	            },
	            meta: {
	                'id': {},
	                'subject': {},
	                'qtexpiredate':{type: 'date'},//需求截止时间
	                'qtoffersSuppierName':{},
	                'statusName':{}//询价单状态
	            },
	            pageSize: 6
			}),

			//根据不同的状态查询订单
            checkingBillStatus: ko.observable(0),
            enquiryBillCount: ko.observable(),
            zbBillCount: ko.observable(),
            biddingBillCount: ko.observable(),
            //供应商数据
            supplyEvaluateData: ko.observableArray(),

             /*点击展示询价*/
            show_enquiry_bills: function () {
                var status = "0";
                self.viewmodel.checkingBillStatus(status);
                self.viewmodel.loadDatas();
                $('#i-accordion').show();
                $("#supply-accordion").hide();
            },
            /*点击展示招标*/
            show_zb_bills: function () {
                var status = "1";
                self.viewmodel.checkingBillStatus(status);
                $('#i-accordion').hide();
                $("#supply-accordion").hide();
            },
            /*展示供应商评分*/
            show_supplyevaluate: function () {
            	var status = "4";
            	self.viewmodel.checkingBillStatus(status);
            	self.viewmodel.loadSupplyEvaluate();
            	$('#i-accordion').hide();
            	$("#supply-accordion").show();
            },
            /*点击展示竞标*/
            show_bidding_bills: function () {
                var status = "3";
                self.viewmodel.checkingBillStatus(status);
                 $('#i-accordion').hide();
                 $("#supply-accordion").hide();
            },
            /*查询供应商评估数据*/
            loadDatas:function(){
            	self.app.serverEvent().addDataTable("quotEntityDataTable").addParameter("enterpriseid",enterpriseid).fire({
		            url: "/yuncai/evt/dispatch",
		            ctrl: "pubportal.BuyofferController",
		            method: 'queryNewestBuyOfferData',
		            success: function (data) {
		            }
            	});
            },
            loadSupplyEvaluate: function () {
            	Common.ajax({
            		url: "/cpu-supplymgr/evaluateScore/loadEvaApplyTask?pageIndex=0&pageSize=6",
            		type: "get",
            		success: function (response) {
            			if (response&&response.status) {
		            		self.viewmodel.supplyEvaluateData(response.data.result)
		            	} else {
		            		console.error("供应商评估查询失败")
		            	}	
            		}
            	})
            }
          
		},
		bindEvents:function(){
			var that = this;
			$("#myproject").delegate(".todo-type", "click", function(e) {});
			window.router.addRouter("#/pages/pricedecision/addcompare", function() {});
		}
	});
	return view;
});